<?xml version='1.0' encoding='UTF-8' ?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<ui:composition xmlns="http://www.w3.org/1999/xhtml"  
                xmlns:h="http://java.sun.com/jsf/html"  
                xmlns:f="http://java.sun.com/jsf/core"
                xmlns:p="http://primefaces.prime.com.tr/ui"
                xmlns:ui="http://java.sun.com/jsf/facelets"
                template="./../templates/StaffTemplate.xhtml">

    <ui:define name="nav_menu">
        <p:menubar model="#{staffChangeInitialPasswordManagedBean.staffMenuModel}"/>
    </ui:define>
    <ui:define name="content"> 
        <h:form>
            <p:panel id="panel" header="Create New Service">
                <f:metadata>
                    <f:viewParam name ="visibility" value ="#{tCubeManagerBean.selectedServicePackage.visibility}" />
                </f:metadata>
                <p:ajaxStatus style="width:16px;height:16px;">
                    <f:facet name="start">
                        <h:graphicImage value="http://www.primefaces.org:8080/showcase/design/ajaxloading.gif" />
                    </f:facet>
                    <f:facet name="complete">
                        <h:outputText value="" />
                    </f:facet>
                </p:ajaxStatus>
                <p:messages />
                <p:dataTable var="servicePackage" value="#{tCubeManagerBean.servicePackages}" paginator="true" 
                             rows="10" emptyMessage="No service pacakge" selection="#{tCubeManagerBean.selectedServicePackage}" 
                             selectionMode="single" rowSelectListener="#{tCubeManagerBean.selectNewServicePackage}" update="servicePackageInfo">
                    <p:column sortBy="#{servicePackage.id}" filterBy="#{servicePackage.id}">
                        <f:facet name="header">
                            <h:outputText value="ID" />
                        </f:facet>
                        <h:outputText value="#{servicePackage.id}" />
                    </p:column>
                    <p:column sortBy="#{servicePackage.name}" filterBy="#{servicePackage.name}">
                        <f:facet name="header">
                            <h:outputText value="Service name" />
                        </f:facet>
                        <h:outputText value="#{servicePackage.name}" />
                    </p:column>
                    <p:column sortBy="#{servicePackage.description}" filterBy="#{servicePackage.description}">
                        <f:facet name="header">
                            <h:outputText value="Description" />
                        </f:facet>
                        <h:outputText value="#{servicePackage.description}" />
                    </p:column>
                </p:dataTable>

                <h:panelGrid columns="3" cellpadding="10" id="servicePackageInfo">
                    <h:outputLabel for="name" style="font-weight: bold" value="Service name: " />
                    <h:inputText required="true" label="Branch Name" requiredMessage="Service name is required." id="name" value="#{tCubeManagerBean.selectedServicePackage.name}">
                    </h:inputText>
                    <p:message for="name" />

                    <h:outputLabel for="description" style="font-weight: bold" value="Description: " />
                    <p:inputTextarea required="true" label="Description" requiredMessage="Description is required." id="description" value="#{tCubeManagerBean.selectedServicePackage.description}">
                    </p:inputTextarea>
                    <p:message for="description" />

                    <h:outputLabel for="price" style="font-weight: bold" value="Price: " />
                    <h:inputText required="true" label="Price" requiredMessage="Price is required." id="price" value="#{tCubeManagerBean.selectedServicePackage.price}">
                    </h:inputText>
                    <p:message for="price" />

                    <h:outputLabel for="priority" style="font-weight: bold" value="Priority: " />
                    <h:selectOneMenu value="#{tCubeManagerBean.selectedServicePackage.priority}">
                        <f:selectItems value="#{tCubeManagerBean.listOfPriority}"/>
                    </h:selectOneMenu>

                    <p:commandButton value="Visible" disabled="#{tCubeManagerBean.selectedServicePackage.visibility}"  action="staff/TCubeEditServicePackageInfo?faces-redirect=true" ajax="true">
                        <f:param name="visibility" value="true" />
                    </p:commandButton>

                    <p:commandButton value="Invisible" disabled="#{!tCubeManagerBean.selectedServicePackage.visibility}" action="staff/TCubeEditServicePackageInfo?faces-redirect=true" ajax="true">
                        <f:param name="visibility" value="false" />
                    </p:commandButton>

                    <h:outputLabel for="blank" style="font-weight: bold" value=""/>
                    <p:dataTable var="service" value="#{tCubeManagerBean.listOfServices}" selection="#{tCubeManagerBean.selectedServices}" paginator="true" rows="10">
                        <p:column selectionMode="multiple" />

                        <p:column headerText="Name">
                            <h:outputText value="#{service.name}" />
                        </p:column>

                        <p:column headerText="Description">
                            <h:outputText value="#{service.description}" />
                        </p:column>
                    </p:dataTable>
                    <p:dataTable var="analytics" value="#{tCubeManagerBean.listOfAnalytics}" selection="#{tCubeManagerBean.selectedAnalytics}" paginator="true" rows="10">
                        <p:column selectionMode="multiple" />

                        <p:column headerText="Name">
                            <h:outputText value="#{analytics.name}" />
                        </p:column>

                        <p:column headerText="Description">
                            <h:outputText value="#{analytics.description}" />
                        </p:column>
                    </p:dataTable>
                </h:panelGrid>
                <p:commandButton id="btn" value="Edit Service Package Info" update="panel" actionListener="#{tCubeManagerBean.editServicePackageInfo}" ajax="true" />
            </p:panel>
        </h:form>
    </ui:define>
</ui:composition>